Dim caption As String = "Example: AddJpegImageFromFile"
Using gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
Dim image_name As String = gdpicturePDF.AddJpegImageFromFile("image.jpg")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4)
If status <> GdPictureStatus.OK Then
Return
End If
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
status = gdpicturePDF.DrawImage(image_name, 0, 0, 210, 297)
If status <> GdPictureStatus.OK Then
Return
End If
status = gdpicturePDF.SaveToFile("Test_AddJpegImage.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your image has been successfully saved to a pdf file.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
End Using
string caption = "Example: AddJpegImageFromFile";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
string image_name = gdpicturePDF.AddJpegImageFromFile("image.jpg");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4);
if (status != GdPictureStatus.OK) return;
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
status = gdpicturePDF.DrawImage(image_name, 0, 0, 210, 297);
if (status != GdPictureStatus.OK) return;
status = gdpicturePDF.SaveToFile("Test_AddJpegImage.pdf");
if (status == GdPictureStatus.OK)
{
MessageBox.Show("Your image has been successfully saved to a pdf file.", caption);
}
else
{
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
}
}